package suneelc.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import suneelc.entity.User;

@Mapper
public interface UserMapper {

    //根据id查找用户
    @Select("select * from user where id = #{id}")
    User selectById(int id);

    //根据名字查找用户
    @Select("select * from user where username=#{username}")
    User selectByName(String username);

    //根据邮箱来查找用户
    @Select("select * from user where email=#{email}")
    User selectByEmail(String email);

    //新增用户
    int insertUser(User user);

    //更新状态
    @Update("update user set status = #{status} where id = #{id}")
    int updateStatus(int id, int status);

    //更新标题
    @Update("update user set header_url=#{hearUrl} where id =#{id}")
    int updateHeader(int id, String headerUrl);

    //更改密码
    @Update("update user set password=#{password} where id =#{id}")
    int updatePassword(int id, String password);
}
